<?php

header('Content-type: text/html');
header('Access-Control-Allow-Origin: *');

require_once('connections/conexion.php');

$usuario = "'" .$_POST['nombre']. "'";
$pass = "'" .$_POST['pass']. "'";
$email = "'" .$_POST['email']. "'";

$consulta = sprintf("INSERT INTO usuarios (nombre, password, email, fecha_ingreso) VALUES (%s, %s, %s, %s)", $usuario, $pass, $email, 'NOW()');
mysql_select_db($database_conexion, $conexion);

if(mysql_query($consulta, $conexion)){
	$consulta2 = "SELECT * FROM usuarios WHERE email = ".$email;
	$peticion = mysql_query($consulta2, $conexion);
	$datos = array();
	
	while($row = mysql_fetch_assoc($peticion)){
		array_push($datos, $row);
	}
	echo json_encode($datos);
}else{
	echo json_encode('KO');
}

?>